package ru.megazlo.basemvc.dao.dto;


import org.springframework.data.annotation.CreatedBy;
import org.springframework.data.annotation.CreatedDate;
import org.springframework.data.annotation.LastModifiedDate;
import org.springframework.data.jpa.domain.AbstractPersistable;
import org.springframework.data.jpa.domain.support.AuditingEntityListener;

import javax.persistence.*;
import java.time.LocalDateTime;
import java.util.Date;

@Entity
@Table(name = "Comments")
@EntityListeners({AuditingEntityListener.class})
public class Comment extends AbstractPersistable<Long> {

	@CreatedDate
	private Date createdDate;
	@LastModifiedDate
	private LocalDateTime lastModifyDate;
	@Column(length = 1000, nullable = false)
	private String textComment;
	@CreatedBy
	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "userId")
	private User owner;
	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "newsId", nullable = false)
	private News news;
}
